<template>
  <div class="todoinput">
    <input type="text" :placeholder="placeholder" v-model="inputValue">
    <button @click="handleClick">{{btnText}}</button>
  </div>
  <Son></Son>
</template>

<script setup>
// 调用defineProps（）定义组件可接收属性
import { ref } from 'vue';
import Son from "./Son.vue"
defineProps({
    placeholder:String,
    btnText:{
        type:String,
        default:"添加"
    }
})

// 调用defineEmists()定义组件可触发事件
 const emit = defineEmits(["add"])

const inputValue = ref("")  
const handleClick = () =>{
    emit("add",inputValue.value)
}
</script>

<style scoped>

</style>
